package com.example.ai_basedintelligentdiagnosisandtreatmentofchildren.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import com.example.ai_basedintelligentdiagnosisandtreatmentofchildren.R;
import com.example.ai_basedintelligentdiagnosisandtreatmentofchildren.model.Alarm;

import java.util.List;

public class AlarmAdapter extends RecyclerView.Adapter<AlarmAdapter.ViewHolder> {

    private List<Alarm> dataList;
    private Context context;

    public AlarmAdapter(List<Alarm> dataList, Context context) {
        this.dataList = dataList;
        this.context = context;
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
        TextView timeValue;
        TextView nameValue;

        public ViewHolder(View view) {
            super(view);
            timeValue = view.findViewById(R.id.timeTextView);
            nameValue = view.findViewById(R.id.nameTextView);
        }
    }

    @Override
    public AlarmAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_medicine_alarm, parent, false);
        return new AlarmAdapter.ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(AlarmAdapter.ViewHolder holder, int position) {
        Alarm alarm = dataList.get(position);

        holder.timeValue.setText(alarm.getTime());
        holder.nameValue.setText(alarm.getMedicineName());
    }

    @Override
    public int getItemCount() {
        return dataList.size();
    }
}